package com.seckill.dao;

import com.seckill.domain.MiaoshaOrder;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author yangjunwei
 * @date 2021/11/1 4:19 下午
 */
@Mapper
public interface MiaoshaOrderDao {

    @Select("select * from miaosha_order where goods_id = #{goodsId} and user_id=#{userId} and order_id =#{orderId}")
    MiaoshaOrder selectMiaoshaOrder(@Param("goodsId") long goodsId, @Param("userId") long userId, @Param("orderId") long orderId);

    @Select("select * from miaosha_order where goods_id = #{goodsId} and user_id=#{userId} ")
    MiaoshaOrder selectMiaoshaOrderByParam(@Param("goodsId") long goodsId, @Param("userId") long userId);

    @Insert("INSERT INTO miaosha_order (`user_id`, `order_id`, `goods_id`) VALUES (#{userId}, #{orderId}, #{goodsId}) ")
    int insertMiaoshaOrder(MiaoshaOrder miaoshaOrder);

    @Delete("delete from miaosha_order where goods_id = #{goodsId} and user_id=#{userId} ")
    int deleteMiaoshaOrder(@Param("goodsId") long goodsId, @Param("userId") long userId);


}
